Skip to content

feat(virtual-lab): add dropdown menu for Chemistry experiments#936

Open
Faraz011 wants to merge 1 commit intoalphaonelabs:mainfrom
Faraz011:chemistry-menu
Open

feat(virtual-lab): add dropdown menu for Chemistry experiments#936
Faraz011 wants to merge 1 commit intoalphaonelabs:mainfrom
Faraz011:chemistry-menu

Conversation

@Faraz011
Copy link

@Faraz011 Faraz011 commented Feb 23, 2026

Description

This PR enhances the Virtual Lab navigation by replacing the static "Chemistry" link with a fully functional dropdown menu, providing direct access to all chemistry experiments.

Key Changes:

  • UI/UX:
    • Replaced the single "Chemistry" navigation link with an interactive dropdown menu.

    • Added menu items for:

      • Titration
      • Reaction Rate
      • Solubility
      • Precipitation
      • pH Indicator
    • Applied consistent styling (w-40, z-50, hover states) to match the existing Physics dropdown for a unified user experience.

Related issues

Fixes #934

Recording.2026-02-23.053849.mp4

Checklist

  • Did you run the pre-commit? (If not, your PR will most likely not pass — please ensure it passes pre-commit)
  • Did you test the change? (Ensure you didn’t just prompt the AI and blindly commit — test the code and confirm it works)
  • Added screenshots to the PR description (if applicable)

Summary by CodeRabbit

  • New Features
    • Chemistry navigation has been enhanced with a dropdown menu, replacing the previous single link. Users can now easily access five chemistry-focused modules: Titration, Reaction Rate, Solubility, Precipitation, and pH Indicator, providing improved organization and discoverability of chemistry-related content.

@github-actions github-actions bot added the files-changed: 1 PR changes 1 file label Feb 23, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 23, 2026

Walkthrough

Added a Chemistry dropdown menu to the Virtual Lab navigation bar with five submenu items (Titration, Reaction Rate, Solubility, Precipitation, pH Indicator), replacing the previous standalone Chemistry link. Minor structural adjustments made to the Physics dropdown. The Code Editor link position remains unchanged.

Changes

Cohort / File(s) Summary
Virtual Lab Navigation Template
web/virtual_lab/templates/virtual_lab/layout.html
Converted Chemistry link to a dropdown menu with five chemistry-related submenu items. Added z-50 stacking context to dropdown container. Made minor structural adjustments to the Physics dropdown.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a dropdown menu for Chemistry experiments in the virtual lab navigation.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #934 requirements: the Chemistry link is replaced with a dropdown menu containing all five specified items (Titration, Reaction Rate, Solubility, Precipitation, pH Indicator) with consistent styling.
Out of Scope Changes check ✅ Passed All changes are scoped to the Chemistry dropdown implementation; minor adjustments to Physics dropdown structure are minor formatting improvements within the overall navigation context.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/virtual_lab/templates/virtual_lab/layout.html`:
- Line 24: The Physics dropdown menu div is missing a z-index and can be
overlaid by the later Chemistry dropdown; update the Physics dropdown container
(the div with classes starting "absolute left-0 mt-2 w-40 bg-white...") to
include the same z-50 class used by the Chemistry dropdown so both dropdowns
have an explicit stacking context and cannot obscure each other.
- Line 24: Remove the stray leading space before the "<div" and the trailing
space inside the class attribute on the Physics dropdown div (the element with
classes ending in "pointer-events-auto"). Edit the div in
virtual_lab/layout.html so it begins with "<div" (no extra leading whitespace)
and the class string has no trailing space before the closing quote, preserving
all other classes and attributes.
- Around line 35-38: Add proper ARIA attributes and button type to make the
dropdown accessible: update the Chemistry dropdown <button> element to include
type="button", aria-haspopup="true" and aria-expanded="false" (and ensure any JS
that opens/closes the menu toggles aria-expanded between "true" and "false"),
and add role="menu" to the dropdown <div> container; apply the same changes to
the Physics dropdown button element referenced in the template to keep behavior
consistent.
- Around line 39-48: Update the Tailwind link color classes on the chemistry
dropdown anchors—specifically the <a> elements pointing to
'virtual_lab:titration', 'virtual_lab:reaction_rate', 'virtual_lab:solubility',
'virtual_lab:precipitation', and 'virtual_lab:ph_indicator'—by replacing the
current "text-gray-700 dark:text-gray-300 hover:bg-... dark:hover:bg-..."
classes with the required link classes "text-blue-600 hover:text-blue-800
dark:text-blue-400" (preserving other layout classes like block, px-4, py-2,
transition as needed).

</button>
<div class="absolute left-0 mt-2 w-40 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto">

<div class="absolute left-0 mt-2 w-40 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto ">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

z-50 applied only to Chemistry dropdown — Physics dropdown risks being overlaid

The Chemistry dropdown menu (line 38) includes z-50, but the Physics dropdown menu (line 24) does not. Because both containers are position: relative; display: inline-block siblings and the Chemistry container appears later in DOM order, the Chemistry container's default stacking order naturally sits above the Physics dropdown menu. Without an explicit z-index on the Physics dropdown, its items can be obscured by the Chemistry container's stacking context, making those items unreachable.

Add z-50 to the Physics dropdown menu div to match:

🐛 Proposed fix — add `z-50` to Physics dropdown
-            <div class="absolute left-0 mt-2 w-40 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto ">
+            <div class="absolute left-0 mt-2 w-40 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto z-50">

Also applies to: 38-38

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/virtual_lab/templates/virtual_lab/layout.html` at line 24, The Physics
dropdown menu div is missing a z-index and can be overlaid by the later
Chemistry dropdown; update the Physics dropdown container (the div with classes
starting "absolute left-0 mt-2 w-40 bg-white...") to include the same z-50 class
used by the Chemistry dropdown so both dropdowns have an explicit stacking
context and cannot obscure each other.

⚠️ Potential issue | 🟡 Minor

Trailing whitespace and extra leading space in the Physics dropdown <div> class

Line 24 has a stray leading space (⎵<div) and a trailing space inside the class string (…pointer-events-auto⎵"). These are cosmetic artifacts from the edit but can cause noise in diffs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/virtual_lab/templates/virtual_lab/layout.html` at line 24, Remove the
stray leading space before the "<div" and the trailing space inside the class
attribute on the Physics dropdown div (the element with classes ending in
"pointer-events-auto"). Edit the div in virtual_lab/layout.html so it begins
with "<div" (no extra leading whitespace) and the class string has no trailing
space before the closing quote, preserving all other classes and attributes.

Comment on lines +35 to +38
<button class="hover:text-indigo-600 dark:hover:text-indigo-400 transition focus:outline-none focus:ring-2 focus:ring-indigo-500">
{% trans "Chemistry" %}
</button>
<div class="absolute left-0 mt-2 w-40 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto z-50">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Missing ARIA attributes on dropdown button and menu container

The <button> has no aria-haspopup, no aria-expanded, and no type="button". The dropdown <div> has no role="menu". Screen readers and assistive technologies will not identify this as a popup menu. Per coding guidelines: "Include proper ARIA labels where needed for accessibility."

type="button" also prevents unintended form submission if this template is ever embedded inside a <form>.

♿ Proposed fix — add ARIA attributes
-            <button class="hover:text-indigo-600 dark:hover:text-indigo-400 transition focus:outline-none focus:ring-2 focus:ring-indigo-500">
+            <button type="button"
+                    aria-haspopup="true"
+                    aria-expanded="false"
+                    class="hover:text-indigo-600 dark:hover:text-indigo-400 transition focus:outline-none focus:ring-2 focus:ring-indigo-500">
               {% trans "Chemistry" %}
             </button>
-            <div class="absolute left-0 mt-2 w-40 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto z-50">
+            <div role="menu"
+                 aria-label="{% trans "Chemistry experiments" %}"
+                 class="absolute left-0 mt-2 w-40 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto z-50">

Note: aria-expanded toggling between "true"/"false" requires a small JS snippet to be fully effective. Apply the same fix to the Physics dropdown button (line 20) for consistency.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button class="hover:text-indigo-600 dark:hover:text-indigo-400 transition focus:outline-none focus:ring-2 focus:ring-indigo-500">
{% trans "Chemistry" %}
</button>
<div class="absolute left-0 mt-2 w-40 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto z-50">
<button type="button"
aria-haspopup="true"
aria-expanded="false"
class="hover:text-indigo-600 dark:hover:text-indigo-400 transition focus:outline-none focus:ring-2 focus:ring-indigo-500">
{% trans "Chemistry" %}
</button>
<div role="menu"
aria-label="{% trans "Chemistry experiments" %}"
class="absolute left-0 mt-2 w-40 bg-white dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md shadow-lg opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition pointer-events-none group-hover:pointer-events-auto group-focus-within:pointer-events-auto z-50">
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/virtual_lab/templates/virtual_lab/layout.html` around lines 35 - 38, Add
proper ARIA attributes and button type to make the dropdown accessible: update
the Chemistry dropdown <button> element to include type="button",
aria-haspopup="true" and aria-expanded="false" (and ensure any JS that
opens/closes the menu toggles aria-expanded between "true" and "false"), and add
role="menu" to the dropdown <div> container; apply the same changes to the
Physics dropdown button element referenced in the template to keep behavior
consistent.

Comment on lines +39 to +48
<a href="{% url 'virtual_lab:titration' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-indigo-50 dark:hover:bg-indigo-900 transition">{% trans "Titration" %}</a>
<a href="{% url 'virtual_lab:reaction_rate' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-green-50 dark:hover:bg-green-900 transition">{% trans "Reaction Rate" %}</a>
<a href="{% url 'virtual_lab:solubility' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-yellow-50 dark:hover:bg-yellow-900 transition">{% trans "Solubility" %}</a>
<a href="{% url 'virtual_lab:precipitation' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-purple-50 dark:hover:bg-purple-900 transition">{% trans "Precipitation" %}</a>
<a href="{% url 'virtual_lab:ph_indicator' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-teal-50 dark:hover:bg-teal-900 transition">{% trans "pH Indicator" %}</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Chemistry dropdown links violate the prescribed Tailwind link color classes

The new links use text-gray-700 dark:text-gray-300 instead of the required text-blue-600 hover:text-blue-800 dark:text-blue-400. As per coding guidelines: "Use Tailwind link classes: text-blue-600 hover:text-blue-800 dark:text-blue-400 for links."

🎨 Proposed fix — apply correct link color classes
-              <a href="{% url 'virtual_lab:titration' %}"
-                 class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-indigo-50 dark:hover:bg-indigo-900 transition">{% trans "Titration" %}</a>
-              <a href="{% url 'virtual_lab:reaction_rate' %}"
-                 class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-green-50 dark:hover:bg-green-900 transition">{% trans "Reaction Rate" %}</a>
-              <a href="{% url 'virtual_lab:solubility' %}"
-                 class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-yellow-50 dark:hover:bg-yellow-900 transition">{% trans "Solubility" %}</a>
-              <a href="{% url 'virtual_lab:precipitation' %}"
-                 class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-purple-50 dark:hover:bg-purple-900 transition">{% trans "Precipitation" %}</a>
-              <a href="{% url 'virtual_lab:ph_indicator' %}"
-                 class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-teal-50 dark:hover:bg-teal-900 transition">{% trans "pH Indicator" %}</a>
+              <a href="{% url 'virtual_lab:titration' %}"
+                 class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-indigo-50 dark:hover:bg-indigo-900 transition">{% trans "Titration" %}</a>
+              <a href="{% url 'virtual_lab:reaction_rate' %}"
+                 class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-green-50 dark:hover:bg-green-900 transition">{% trans "Reaction Rate" %}</a>
+              <a href="{% url 'virtual_lab:solubility' %}"
+                 class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-yellow-50 dark:hover:bg-yellow-900 transition">{% trans "Solubility" %}</a>
+              <a href="{% url 'virtual_lab:precipitation' %}"
+                 class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-purple-50 dark:hover:bg-purple-900 transition">{% trans "Precipitation" %}</a>
+              <a href="{% url 'virtual_lab:ph_indicator' %}"
+                 class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-teal-50 dark:hover:bg-teal-900 transition">{% trans "pH Indicator" %}</a>

As per coding guidelines: "Use Tailwind link classes: text-blue-600 hover:text-blue-800 dark:text-blue-400 for links."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<a href="{% url 'virtual_lab:titration' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-indigo-50 dark:hover:bg-indigo-900 transition">{% trans "Titration" %}</a>
<a href="{% url 'virtual_lab:reaction_rate' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-green-50 dark:hover:bg-green-900 transition">{% trans "Reaction Rate" %}</a>
<a href="{% url 'virtual_lab:solubility' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-yellow-50 dark:hover:bg-yellow-900 transition">{% trans "Solubility" %}</a>
<a href="{% url 'virtual_lab:precipitation' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-purple-50 dark:hover:bg-purple-900 transition">{% trans "Precipitation" %}</a>
<a href="{% url 'virtual_lab:ph_indicator' %}"
class="block px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-teal-50 dark:hover:bg-teal-900 transition">{% trans "pH Indicator" %}</a>
<a href="{% url 'virtual_lab:titration' %}"
class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-indigo-50 dark:hover:bg-indigo-900 transition">{% trans "Titration" %}</a>
<a href="{% url 'virtual_lab:reaction_rate' %}"
class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-green-50 dark:hover:bg-green-900 transition">{% trans "Reaction Rate" %}</a>
<a href="{% url 'virtual_lab:solubility' %}"
class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-yellow-50 dark:hover:bg-yellow-900 transition">{% trans "Solubility" %}</a>
<a href="{% url 'virtual_lab:precipitation' %}"
class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-purple-50 dark:hover:bg-purple-900 transition">{% trans "Precipitation" %}</a>
<a href="{% url 'virtual_lab:ph_indicator' %}"
class="block px-4 py-2 text-blue-600 hover:text-blue-800 dark:text-blue-400 hover:bg-teal-50 dark:hover:bg-teal-900 transition">{% trans "pH Indicator" %}</a>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/virtual_lab/templates/virtual_lab/layout.html` around lines 39 - 48,
Update the Tailwind link color classes on the chemistry dropdown
anchors—specifically the <a> elements pointing to 'virtual_lab:titration',
'virtual_lab:reaction_rate', 'virtual_lab:solubility',
'virtual_lab:precipitation', and 'virtual_lab:ph_indicator'—by replacing the
current "text-gray-700 dark:text-gray-300 hover:bg-... dark:hover:bg-..."
classes with the required link classes "text-blue-600 hover:text-blue-800
dark:text-blue-400" (preserving other layout classes like block, px-4, py-2,
transition as needed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

files-changed: 1 PR changes 1 file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue: Missing Chemistry Dropdown Menu in Virtual Lab Navigation

1 participant